import asyncio
import utils
import os
import task

async def main():
    directory_path = os.path.join(os.getcwd(), 'test_cases', 'source_code')
    source_path = os.path.join(os.getcwd(), 'test_cases', 'template')
    for root, dirs, files in os.walk(directory_path):
      for directory in dirs:
          if (os.path.join(root, directory).endswith('src')):
              print(f"子目录: {os.path.join(root, directory).replace('src', '')}")
              target_path = os.path.join(root, directory).replace('source_code', 'transformed_code')
              target_path = target_path.replace('src', '')
              print("source_path: "+source_path)
              print("target_path: "+target_path)
              utils.copy_template(source_path, target_path)
      for filename in files:
          if (filename.endswith('.vue')):
            source_file_path = os.path.join(root, filename)
            print(f"文件: {source_file_path}")

            h5_code = utils.get_h5_code(source_file_path)

            task.get_code_result(h5_code, source_file_path)

asyncio.run(main())
